package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

import modell.Urverk;

public class StoppeKnapp extends JButton implements ActionListener {

	private static final long serialVersionUID = -7729791150016875911L;
	
	private Urverk ur;

	public StoppeKnapp(Urverk ur){
		super("Stopp");
		this.ur = ur;
		addActionListener(this);
	}
	
	private void startStopp(){
		if (ur.kjorer())
			ur.stopp();
		else
			ur.start();
	}
	
	private void endreTekst() {
		setText((ur.kjorer()? "Stopp" : "Start"));
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		startStopp();
		endreTekst();
	}

}
